package test1;

import java.util.Random;

public class Role {
    private String name;
    private int blood;
    private String gender;
    private String attackMethod;

    public Role(String name, int blood, String gender, String attackMethod) {
        this.name = name;
        this.blood = blood;
        this.gender = gender;
        this.attackMethod = attackMethod;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getAttackMethod() {
        return attackMethod;
    }

    public void setAttackMethod(String attackMethod) {
        this.attackMethod = attackMethod;
    }

    public void attack(Role role) {
        Random r = new Random();
        int hurt = r.nextInt(100) + 1;
        int remainBlood = role.getBlood() - hurt;
        remainBlood = Math.max(0, remainBlood);
        role.setBlood(remainBlood);

        System.out.println(this.getName() + this.getAttackMethod() + "，击中" + role.getName() +
                "造成了" + hurt + "点伤害，" + role.getName() + "还剩下" + remainBlood + "点血量");

    }

    public void escape(){

    }


}
